-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Fix to lzma.LZMAFile #30010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: Fix to lzma.LZMAFile #30010
Conversation
pandas/compat/__init__.py
Outdated
@@ -123,7 +123,7 @@ def _get_lzma_file(lzma): | |||
|
|||
Returns | |||
------- | |||
class | |||
lzma.LZMAFile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly type(LZMAFile)
? usually this would indicate that we're getting an instance of that class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should annotate the function return here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should annotate the function return here as well
I thought of that. but the problem is that the function tests for the imports of the lzma
module. If I import it beforehand it kinda losing it's point (I think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should annotate the function return here as well
@WillAyd I tried it now, I imported the lzma
module at the beginning of the file and annotated _get_lzma_file
with -> lzma.LZMAFile
, and mypy
complained:
pandas/io/common.py:468: error: "LZMAFile" not callable
Any thoughts?
pandas/compat/__init__.py
Outdated
@@ -123,7 +123,7 @@ def _get_lzma_file(lzma): | |||
|
|||
Returns | |||
------- | |||
class | |||
lzma.LZMAFile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should annotate the function return here as well
It would need to be Type[lzma.LZMAFile], though not sure if we can do that given this is technically an optional dependency from the stdlib |
Does Type[IO] work? May be the best bet |
LZMA has been part of the standard library since python 3.3. We should just assume it’s installed, that will simplify this a bit. |
I'm pretty sure that just recently i had to do an apt-get install to get this working on an ubuntu 18 machine |
We had an issue previously with that assumption, hence the existence of this compat to begin with. See #27575 |
Ok, that’s surprising. Yeah, changing it isn’t possible then, I guess... |
|
I just found a bug (I think), unless I'm missing something obvious. When
But if the
So two questions actually:
|
Thanks @MomIsBestFriend Can come back to types later for the whole module if something you are interested in |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff